# 构建用户画像
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics.pairwise import cosine_similarity


class UserProfile:
    def __init__(self, skills, city, demand, salary):
        self.skills = skills
        self.city = city
        self.demand = demand
        self.salary = salary


user_profile = UserProfile(
    skills=["Python", "Data Analysis"],
    city="New York",
    demand="实习",
    salary=10000)

def recommend_positions(user_profile, knowledge_graph):
    recommended_positions = []


# 假设这是知识图谱中的一些职位
knowledge_graph = {
    "positions": [
        {"title": "Data Scientist", "required_skills": ["Python", "Machine Learning"], "city": "New York", "salary": 120000},
        # ... 其他职位
    ]
}

# 获取推荐
recommended_positions = recommend_positions(user_profile, knowledge_graph)


if __name__ == '__main__':
    # 示例数据
    user_profile = {"skills": "Python,gfd"}
    job_position = {"skills": "Python,gfd"}

    # 将技能转换为向量
    vectorizer = CountVectorizer(tokenizer=lambda x: x.split(','))
    job_vector = vectorizer.fit_transform([job_position["skills"]])
    user_vector = vectorizer.transform([user_profile["skills"]])

    # 计算余弦相似度
    similarity = cosine_similarity(user_vector, job_vector)
    print(f"相似度: {similarity[0][0]}")
